<template>
  <div  class="content">
    <!-- 表格 -->
    <el-table
      :data="tableData"
      border
      stripe
      style="width: 100%">
      <el-table-column
        type="index"
        label="序号"
        width="50">
      </el-table-column>

      <el-table-column
        prop="account"
        label="审批管理员">
      </el-table-column>

      <el-table-column
        prop="password"
        label="设置权限">
        <tempolate slot-scope="{row}">
          <el-checkbox-group v-model="row.permission">
            <el-checkbox label="one" name="type">一审</el-checkbox>
            <el-checkbox label="two" name="type">二审</el-checkbox>
            <el-checkbox label="end" name="type">终审</el-checkbox>
          </el-checkbox-group>
        </tempolate>
      </el-table-column>


      <el-table-column label="操作" >
        <template slot-scope="{row}">
          <el-button
            size="mini"
            type="danger"
            @click="handleSubmit(row)" >修改权限</el-button>
        </template>
      </el-table-column>

    </el-table>
  </div>
</template>

<script>
import {permissionApprove,permissionUpd} from '@/api/http'

export default {
  data(){
    return {
      tableData:[], //表格数据
    }
  },
  mounted(){
    this.getData();
  },
  methods:{
    //获取数据
    getData(){
      permissionApprove().then(res=>{
        let {code,data} = res.data;
        if(code==20000){
          this.tableData = data.list;
        }
      })
    },
    //修改权限
    handleSubmit(row){
      let {id,user_id,permission} = row;
      permissionUpd({id,user_id,permission}).then(res=>{
        let {code} = res.data;
        if(code==20000){
          this.getData();
          this.$notify({
            title: '修改权限',
            message: '修改权限成功',
            duration: 2000,
            type: 'success'
          });
        }
      })
    }
  }
}
</script>


